define(['router'], function () {
    var topNav = angular.module('topNav', []);
    topNav.controller('topNavCtrl', ['$rootScope', '$scope', '$http', '$state', "COOKIES", function ($rootScope, $scope, $http, $state, cookie) {
        $scope.menu = {
            url: "app/framework/top_nav.html"
        }

        $scope.navList = [{
            state: "portal",
            text: "主页",
            href: "#/portal"
        }, {
            state: "portal.user",
            text: "用户管理",
            href: "#/portal/user"
        }, {
            state: "portal.interview",
            text: "面试题",
            href: "#/portal/interview"
        }, {
            state: "portal.blog",
            text: "博客",
            href: "#/portal/blog"
        }, {
            state: "portal.eoms",
            text: "运维",
            href: "#/portal/eoms"
        }];
        $rootScope.isLoginPage = false;

        if (!cookie.getCookie("LoginName")) {
            $rootScope.isLoginPage = true;
            $state.go("login");
        } else {
            $scope.UserName = cookie.getCookie("UserName");
        }
        $scope.logout = function () {
            cookie.delCookie("LoginName");
            cookie.delCookie("UserName");
            cookie.delCookie("UserID");
            $rootScope.isLoginPage = true;
            $rootScope.isLoginNav = true;
            window.location.href = "#/login";
        }

    }]);
    return topNav;
});